home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pine / osdep / hostname.hom < prev    next >
Text File  |  1993-07-15  |  1KB  |  50 lines

  1. /*----------------------------------------------------------------------
  2.        Supplimentary hostname if the system doesn't have gethostname
  3.  
  4.   Args: hostname -- Buffer to return host name in 
  5.         size     -- Size of buffer hostname is to be returned in
  6.  
  7.   Results: Returns the current host's name
  8.   ----------------------------------------------------------------------*/
  9. hostname(hostname,size) 
  10.      char *hostname;
  11.      int size;
  12. {
  13. #ifdef SYSTEMID
  14.     char    buf[32];
  15.     FILE    *fp;
  16.     char    *p;
  17.  
  18.     if ((fp = fopen("/etc/systemid", "r")) != 0) {
  19.       fgets(buf, sizeof(buf) - 1, fp);
  20.       fclose(fp);
  21.       if ((p = strindex(buf, '\n')) != NULL)
  22.         *p = '\0';
  23.       (void) strncpy(hostname, buf, size - 1);
  24.       hostname[size - 1] = '\0';
  25.       return 0;
  26.     }
  27.  
  28. #else   /* SYSTEMID */
  29.  
  30. #ifdef DOUNAME
  31.     /** This routine compliments of Scott McGregor at the HP
  32.         Corporate Computing Center **/
  33.      
  34.     int uname();
  35.     struct utsname name;
  36.  
  37.     (void) uname(&name);
  38.     (void) strncpy(hostname,name.nodename,size-1);
  39. #else
  40.     (void) strncpy(hostname, HOSTNAME, size-1);
  41. #endif    /* DOUNAME */
  42.  
  43.     hostname[size - 1] = '\0';
  44.     return 0;
  45.  
  46. #endif  /* XENIX */
  47. }
  48.  
  49.  
  50.